package com.xsomnus.java_basic.bitops;

import java.util.Arrays;
import java.util.Comparator;
import java.util.SortedSet;
import java.util.TreeSet;

/**
 * @author 叶小夏
 * @since 2019-08-23 15:44
 */
public class SegmentProtocolTest {

    public static void main(String[] args) {
        SegmentDefinition msgPart = new SegmentDefinition("msg", 0x04, 8, 4);
        SegmentDefinition cmdPart = new SegmentDefinition("cmd", 0x03, 8, 1);
        SegmentDefinition typePart = new SegmentDefinition("type", 0x01, 8, 2);
        SegmentDefinition versionPart = new SegmentDefinition("version", 0x01, 8, 3);


        SortedSet<SegmentDefinition> segmentDefinitions = new TreeSet<>(Comparator.comparingInt(SegmentDefinition::getSeqId));
        segmentDefinitions.addAll(Arrays.asList(typePart, versionPart, cmdPart, msgPart));
        IntProtocol intProtocol = new IntProtocol(segmentDefinitions);
        segmentDefinitions.forEach(System.out::println);

        int val = intProtocol.getVal();
        System.out.println(val);

    }

}
